package cn.tedu.lonnghospital.appointment.web;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

import static cn.tedu.lonnghospital.appointment.web.ServiceCode.OK;

@Data
@Accessors(chain = true)
public class JsonResult implements Serializable {
    private Integer state;
    private String message;
    private Object data;

    public static JsonResult ok(){
        return JsonResult.ok(null);
    }
    public static JsonResult ok(Object data){
        JsonResult jsonResult=new JsonResult();
        jsonResult.setState(OK.getValue());
        jsonResult.setData(data);
        return jsonResult;
    }

    public static JsonResult fail(ServiceCode state,String message){
        JsonResult jsonResult=new JsonResult();
        jsonResult.setState(state.getValue());
        jsonResult.setMessage(message);
        return jsonResult;
    }
}
